<?php
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


$fields = array("salary" => "เงินเดือนพนักงาน"
    , "tax" => "ภาษี"
    , "tax1" => "ภาษีหัก ณ ที่จ่าย"
    , "cremation1" => "ก.ฌ."
    , "welfare" => "สวัสดิการ"
    , "cooperative" => "สหกรณ์"
    , "loan" => "กู้เทศบาล"
    , "bongkum" => "ธนาคารออมสิน (บงคำ)"
    , "ghb" => "ธนาคารอาคารสงเคราะห์"
    , "aia" => "AIA"
    , "cremation2" => "กฌ.เทศบาล"
    , "total1" => "อื่นๆ");
?>

<table id="chq" class="table table-bordered table-hover" width="60%" >
    <caption><br></caption>
    <thead>
        <tr>
            <th>#</th>
            <th>รายการ</th>
            <th>จำนวนเงิน</th>
            <th>action</th>
        </tr>
    </thead>
    <tbody>
        <?php
        $db = NEW myDBS();
        
        foreach ($fields as $key => $value) {

            $sql = "SELECT sum(tbl_init.$key) AS s "
                    . " FROM tbl_salary, tbl_init "
                    . " WHERE tbl_salary.id = tbl_init.card_id ";

//            echo $sql . ";<br>";

            $result = $db->runSQL($sql);

            $r = $db->fetch_object($result);
            ?>
            <tr>
                <td>&nbsp;</td>
                <td><?= $value ?></td>
                <td><p class="text-right"><?= $r->s ?></p></td>
                <td><p class="text-center"><a href="index.php?pages=chq_salary_save&key=<?=$key?>&s=<?=$r->s?>"><i class="icon-print"></i></a></p></td>
            </tr>
            <?php
        }
        ?>
    </tbody>
</table>



